package it.traveldream.customer;

import it.traveldreamClient.beans.ClientManagerInterface;
import it.traveldreamClient.beans.GestoreRichiesteBeanInterface;
import it.traveldreamClient.beans.PacchettiMgrBeanInterface;
import it.traveldreamClient.beans.UserMgr;
import it.traveldreamClient.beans.dto.RichiestaDTO;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;



@ManagedBean(name="requestMB")
@SessionScoped
public class RichiestaManagedBean {
	
	@EJB
	private GestoreRichiesteBeanInterface mrq;
	@EJB
	private UserMgr usr;


	
	private String idPkg;
	private String codiceRichiesta;
	private RichiestaDTO rDTO;


	public RichiestaManagedBean() {
		super();
		
	}


	public String getIdPkg() {
		return idPkg;
	}


	public GestoreRichiesteBeanInterface getMrq() {
		return mrq;
	}


	public void setMrq(GestoreRichiesteBeanInterface mrq) {
		this.mrq = mrq;
	}


	public UserMgr getUsr() {
		return usr;
	}


	public void setUsr(UserMgr usr) {
		this.usr = usr;
	}


	public String getCodiceRichiesta() {
		return codiceRichiesta;
	}


	public void setCodiceRichiesta(String codiceRichiesta) {
		this.codiceRichiesta = codiceRichiesta;
	}


	public RichiestaDTO getrDTO() {
		return rDTO;
	}


	public void setrDTO(RichiestaDTO rDTO) {
		this.rDTO = rDTO;
	}


	public void setIdPkg(String idPkg) {
		this.idPkg = idPkg;
	}
	
	public void register(){
		rDTO = new RichiestaDTO();
		rDTO.setMailMittente(usr.getMailActualUser());
		rDTO.setPkgPersonalizzato(mrq.getPkgPersonal(idPkg));
		rDTO.setRichiesteAccettate(0);
		
		codiceRichiesta= mrq.salvaRichiesta(rDTO);
		
	}
	
	
	
	
	
}
